package com.pp.ent;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.pp.ent.base.concurrent.XLCommand;
import com.pp.ent.core.manage.CoreManager;
import com.pp.ent.view.InjectUtils;

/**
 * Author:dengqu
 * Date:2016/7/26
 */
public class Cherry {
    private Cherry(){}
    /**
     * 进行界面视图的绑定，view的注入，消息通讯的注入
     * @param activity
     */
    public static void injectActivity(Activity activity){
        InjectUtils.injectActivity(activity);
        CoreManager.addClient(activity);
    }

    public static View injectFragment(Fragment fragment, LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState){
       return InjectUtils.injectFragment(fragment,inflater,container,savedInstanceState);
    }
    /**
     * 普通类注入
     * @param object
     */
    public static void injectObject(Object object){
        InjectUtils.injectObject(object);
        CoreManager.addClient(object);
    }

    /**
     * 通知ui
     * @param key
     * @param args
     */
    public static void notifyUI(String key, Object... args){
        CoreManager.noifyUI(key,args);
    }

    /**
     * 通知ui
     */
    public static void notifyUI(XLCommand command){
        CoreManager.noifyUI(command);
    }

    /**
     * 通知service
     * @param key
     * @param args
     */
    public static void notifyService(String key, Object... args){
        CoreManager.noifyService(key,args);
    }

    /**
     * 解绑，移除监听，防止内存泄漏
     * @param object
     */
    public static void remove(Object object){
        CoreManager.remove(object);
    }


}
